//
//  FrameGenParamGenMultiplexer.h
//  note-recog
//
//  Created by Philip Home on 16/05/2013.
//  Copyright (c) 2013 None. All rights reserved.
//

#ifndef note_recog_FrameGenParamGenMultiplexer_h
#define note_recog_FrameGenParamGenMultiplexer_h

#include <memory>
#include <vector>
#include "IFrameGenParamGen.h"


class FrameGenParamGenMultiplexer : public IFrameGenParamGen
{
private:
    std::vector<std::shared_ptr<IFrameGenParamGen> > _children;
    float _duration;
public:
    FrameGenParamGenMultiplexer(std::vector<std::shared_ptr<IFrameGenParamGen>> children)
    : _children(children),
      _duration(0.f)
    {
        for(auto &it : _children)
        {
            _duration = std::max(_duration, it->duration());
        }
    }
    
    virtual std::vector<FrameGenParam> getComponentParams(float t) const
    {
        std::vector<FrameGenParam> results;
        for(auto &it : _children)
        {
            const IFrameGenParamGen& gen(*it);
            std::vector<FrameGenParam> contrib = gen.getComponentParams(t);
            results.insert(results.end(), contrib.begin(), contrib.end());
        }
        return results;
    }
    
    virtual float duration() const { return _duration; }
};


#endif